import store from '@/store';
import {Action, Module, Mutation, VuexModule} from 'vuex-class-modules';

const DEFAULT_AVATAR_URL = process.env.VUE_APP_DEFAULT_AVATAR_URL;

/**
 * 头像
 */
@Module
class AvatarModule extends VuexModule {
  /**
   * 头像地址
   */
  public url?: string = DEFAULT_AVATAR_URL;

  get getUrl() {
    return this.url;
  }

  @Mutation
  public setUrl(url?: string) {
    this.url = url;
  }

  @Action
  public async change(url?: string) {
    this.setUrl(url);
  }
}

export default new AvatarModule({store, name: 'avatar'});
